import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
// 避免重复点击
// const originalPush = VueRouter.prototype.push
// VueRouter.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch(err => err)
// }
// const originalPush = VueRouter.prototype.push
//    VueRouter.prototype.push = function push(location) {
//    return originalPush.call(this, location).catch(err => err)
// }
/* Layout */
import Layout from '../views/layout/index'
export const constantRouterMap = [
  { path: '/', 
    component: Layout,
    redirect: '/kanban',
    meta: {title: '首页', hidden: true},
    children:[{
      path: '/welcome', 
      component: () => import('@/views/common/welcome'),
      meta: {title: '欢迎界面', hidden: true},
    }]
  }, 

]


export const asyncRouterMap = [
  

  { path: '/manage',  component: Layout,  meta: {title: '基础资料', icon: 'icon-Menu_normal', hidden:false},
    children:[
      { path: '/rule', name: 'rule',  component: () => import('@/views/manage/menu'), meta: {title: '菜单管理',hidden: false}},
      { path: '/site', name: 'site', component: () => import('@/views/manage/site'), meta: {title: '站点管理', icon: 'icon_set_normal', hidden: false}},
    ]
  },
  {path: '/index', component: Layout, meta: {title: '首页管理', hidden: false,icon:'icon-Home_normal'},
    children:[
      { path: '/banner',  name: 'banner',  component: () => import('@/views/home/banner'), meta: {title: 'BANNER管理',hidden: false} },
      { path: '/banner_article',  name: 'banner_article', component: () => import('@/views/home/bannerArticle'), meta: {title: '卡片-文章管理',hidden: false,}},
      { path: '/banner_product',  name: 'banner_product', component: () => import('@/views/home/bannerProduct'), meta: {title: '卡片-产品管理',hidden: false,}},
      { path: '/social_media',  name: 'social_media', component: () => import('@/views/home/socialMedia'), meta: {title: '社媒管理',hidden: false,}},
      { path: '/special',  name: 'special', component: () => import('@/views/home/special'), meta: {title: '专题管理',hidden: false,}},
      { path: '/module_customization',  name: 'module_customization', component: () => import('@/views/home/module_customization'), meta: {title: '模块自定义管理',hidden: false,}},

      
    ]
  }, 
  {path: '/product', component: Layout, meta: {title: '产品管理', hidden: false,icon:'icon-Home_normal'},
    children:[
      { path: '/product_type',  name: 'product_type', component: () => import('@/views/product/productType'), meta: {title: '产品类型管理',hidden: false,}, },
      { path: '/product_comment',  name: 'product_comment', component: () => import('@/views/product/productComment'), meta: {title: '产品评论管理',hidden: false,}, },
      { path: '/product_basic',  name: 'product_basic', component: () => import('@/views/product/productBasic'), meta: {title: '产品管理',hidden: false,}, },
      { path: '/product_color',  name: 'product_color', component: () => import('@/views/product/productColor'), meta: {title: '颜色管理',hidden: false,}, },
      { path: '/product_specification_mannage',  name: 'product_specification_mannage', component: () => import('@/views/product/productSpecification'), meta: {title: '规格管理',hidden: false,}, },
      { path: '/agency',  name: 'agency', component: () => import('@/views/product/agency'), meta: {title: '经销商管理',hidden: false,}, },
      { path: '/instructions',  name: 'instructions', component: () => import('@/views/product/instructions'), meta: {title: '说明书管理',hidden: false,}, },
      { path: '/product_import_export',  name: 'product_import_export', component: () => import('@/views/product/product_import_export'), meta: {title: '产品进出口管理',hidden: false,}, },      
      { path: '/material',  name: 'material', component: () => import('@/views/product/material'), meta: {title: '材质管理',hidden: false,}, },      

     ]
  }, 
  {path: '/article', component: Layout, meta: {title: '文章管理', hidden: false,icon:'icon-Home_normal'},
  children:[
    { path: '/article_manage',  name: 'article_manage', component: () => import('@/views/article/article_manage'), meta: {title: '文章管理',hidden: false,}, },
    { path: '/article_tag_type',  name: 'article_tag_type', component: () => import('@/views/article/article_tag_type'), meta: {title: '标签类型管理',hidden: false,}, },
    { path: '/article_type',  name: 'article_type', component: () => import('@/views/article/article_type'), meta: {title: '文章类型管理',hidden: false,}, },
    { path: '/article_comment',  name: 'article_comment', component: () => import('@/views/article/article_comment'), meta: {title: '文章评论管理',hidden: false,}, },

  ]
}, 
  {path: '/front', component: Layout, meta: {title: '前端管理', hidden: false,icon:'icon-Home_normal'},
    children:[
      { path: '/front_menu',  name: 'product_type', component: () => import('@/views/front/frontMenu'), meta: {title: '前端菜单管理',hidden: false,}, },
    ]
  }, 
  {path: '/customer', component: Layout, meta: {title: '客户管理', hidden: false,icon:'icon-Home_normal'},
    children:[
      { path: '/customer',  name: 'customer', component: () => import('@/views/customer/customer'), meta: {title: '客户管理',hidden: false,}, },
      { path: '/after_sale',  name: 'after_sale', component: () => import('@/views/customer/afterSales'), meta: {title: '售后管理',hidden: false,}, },
      { path: '/equipment',  name: 'equipment', component: () => import('@/views/customer/equipment'), meta: {title: '设备管理',hidden: false,}, },
    ]
  }, 
  {path: '/attachment', component: Layout, meta: {title: '图库管理', hidden: false,icon:'icon-Home_normal'},
    children:[
      { path: '/attachment',  name: 'gallery', component: () => import('@/views/gallery/gallery'), meta: {title: '图库管理',hidden: false,}, },
      { path: '/QRcode',  name: 'QRcode', component: () => import('@/views/gallery/QRcode'), meta: {title: '二维码管理',hidden: false,}, },
    ]
  }, 
  {path: '/kanban', component: Layout, meta: {title: '看板管理', hidden: false,icon:'icon-Home_normal'},
    children:[ 
      { path: '/kanban',  name: 'kanban', component: () => import('@/views/kanban/index.vue'), meta: {title: '看板管理',hidden: false,}, },
    ]  
  }, 
  {path: '/FAQ_management', component: Layout, meta: {title: 'FAQ管理', hidden: false,icon:'icon-Home_normal'},
    children:[ 
      { path: '/faq_type',  name: 'faq_type', component: () => import('@/views/support/faqType'), meta: {title: 'FAQ类型管理',hidden: false,}, },
      { path: '/faq',  name: 'faq', component: () => import('@/views/support/faq'), meta: {title: 'FAQ管理',hidden: false,}, },
      { path: '/file_type',  name: 'fileType', component: () => import('@/views/support/fileType'), meta: {title: '文件类型管理',hidden: false,}, },
      { path: '/files',  name: 'file', component: () => import('@/views/support/files'), meta: {title: '文件管理',hidden: false,}, },
    ]  
  }, 
  {path: '/AboutUs', component: Layout, meta: {title: 'FAQ管理', hidden: false,icon:'icon-Home_normal'},
    children:[ 
      { path: '/warranty_policy', name: 'warranty_policy',  component: () => import('@/views/aboutus/warrantyPolicy'), meta: {title: 'Warranty Policy',hidden: false}},
      { path: '/our_story',  name: 'our_story', component: () => import('@/views/aboutus/ourStory'), meta: {title: 'Our Story',hidden: false,}, },
    ]  
  }, 



]

export default new VueRouter({
  mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap.concat(asyncRouterMap)
})
